# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

project ( lua_circular_buffer C )
cmake_minimum_required ( VERSION 3.0 )
include ( cmake/dist.cmake )
include ( lua )

if(MSVC)
    # Predefined Macros: http://msdn.microsoft.com/en-us/library/b0084kay.aspx
    # Compiler options: http://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx
    # set a high warning level and treat them as errors
    set(CMAKE_C_FLAGS           "/W3 /WX")

    # debug multi threaded dll runtime, complete debugging info, runtime error checking
    set(CMAKE_C_FLAGS_DEBUG     "/MDd /Zi /RTC1")

    # multi threaded dll runtime, optimize for speed, auto inlining
    set(CMAKE_C_FLAGS_RELEASE   "/MD /O2 /Ob2 /DNDEBUG")
else()
    # Predefined Macros: clang|gcc -dM -E -x c /dev/null
    # Compiler options: http://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html#Invoking-GCC
    set(CMAKE_C_FLAGS   "-std=gnu99 -pedantic -Werror -Wall -Wextra")
    if (NOT WIN32)
        set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -fPIC")
    else()
        set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -D__USE_MINGW_ANSI_STDIO")
    endif()
    set(CMAKE_C_FLAGS_DEBUG     "-g")
    set(CMAKE_C_FLAGS_RELEASE   "-O2 -DNDEBUG")
endif()

add_definitions ( -DDIST_VERSION="${DIST_VERSION}" )
install_lua_module ( circular_buffer lua_circular_buffer.c cephes.c lua_circular_buffer.def )
install_doc ( README.md )
add_lua_test ( test.lua )
